package com.kyxx.mycommonproject.sousuo.model;

import android.content.Context;
import android.view.View;

import com.kyxx.mycommonproject.R;
import com.kyxx.mycommonproject.sousuo.model.callBack.SearchSimilarListener;
import com.kyxx.mycommonproject.sousuo.model.impl.SearchSimilarImpl;

import java.util.ArrayList;
import java.util.Arrays;

/**
 * Created by Administrator on 2016/9/9.
 */
public class SearchSimilarModel implements SearchSimilarImpl{
    private ArrayList<String> mCountries;

    @Override
    public void getSearchSimilarData(String content, Context ctx, SearchSimilarListener listener) {
        String[] country = ctx.getResources().getStringArray(R.array.countries_array);
        mCountries = new ArrayList<String>(Arrays.asList(country));
        ArrayList<String> filterList = new ArrayList<String>();
        for (int i = 0; i < mCountries.size(); i++) {
            if (mCountries.get(i).toLowerCase().startsWith(content.trim().toLowerCase())) {
                filterList.add(mCountries.get(i));
                listener.onSuccess(filterList);
            }
        }
    }

}
